﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;

/// <summary>
/// Summary description for Monthly_Process
/// </summary>
/// 

namespace Bestlife.ERP.BusinessRules
{
  
public class Monthly_Process
{
    String dte;
    string status;
    public DateTime crrntdte;
    String userId;
    Double product_bv;
    Double product_pv;
    Double product_tpv;
    Double product_sales;
    List<String> getchilds= new List<string>();


	public Monthly_Process()
	{
		//
		// TODO: Add constructor logic here

   # region update user pv value to 0
        
        
        Boolean upd = false;

        try
        {

            String connStr = ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString;
            Bestlife.ERP.DataAccess.clsCon.connect(connStr);

            String updtxt = "UPDATE Bonus  SET pv='0.00', bv='0.00'";

            upd = Bestlife.ERP.DataAccess.clsCon.AddEditDel(updtxt);

        }
        catch (Exception Ex)
        {

            //Response.Redirect("Massages.aspx?Massage=" + Ex.Message.ToString());
        }
        finally
        {
            Bestlife.ERP.DataAccess.clsCon.conn_new.Close();
        }

        #endregion


    }


   #region Month Check

    public string monthcheck ()
    {

	DateTime time = DateTime.Now;              // Use current time
    string format = "MMM ddd d HH:mm yyyy";    // Use this format
    Console.WriteLine(time.ToString(format));



                      String connStr = ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString;
                      Bestlife.ERP.DataAccess.clsCon.connect(connStr);

                      String Ssql = "SELECT User_id,Parent_To_User FROM   Distributor_Level WHERE  Parent_To_User=(SELECT MAX(Parent_To_User) FROM Distributor_Level)";
                      

                      SqlDataReader rdR;
                      rdR = DataAccess.clsCon.ReadTable(Ssql);


                      while (rdR.Read())
                      {
                          userId = rdR["User_id"].ToString();

                          getchilds.Add(userId);




                          //product_bv = Double.Parse(rdR["Bv"].ToString());
                        //  product_pv = Double.Parse(rdR["ppv"].ToString());
                        //  product_sales = Double.Parse(rdR["T_sales"].ToString());

                        //  DataAccess.calculations cals = new DataAccess.calculations();
                        //  cals.calculationss(userId, product_bv, product_pv, product_sales);


                          
                      }

                      rdR.Close();
                      BusinessRules.update_Status ch = new update_Status();
                      ch.Get_child_node(getchilds);


                          //if ((dte.Equals("January 26") || dte.Equals("February 26") || dte.Equals("March 26") || dte.Equals("April 26") || dte.Equals("May 26") || dte.Equals("June 26") || dte.Equals("July 26") || dte.Equals("August 26") || dte.Equals("September 26") || dte.Equals("October 26") || dte.Equals("November 26") || dte.Equals("December 26")))
                          //{


                            

                          //}

                     


    return status;

    }

    #endregion


}

}